﻿<?php
include_once('conn.php');
class loginInfo
{
	public $userid=0;
	public $username="";
	public $success=false;
	public $msg="";
}
$info=new loginInfo;
$username = @htmlspecialchars($_COOKIE["username"]);
$id = @$_COOKIE["userid"];
$info->username=$username;
$info->userid=$id;
if(!isset($_COOKIE["username"]))
{
	echo "请登录!";
	die("");
}
$Sql=$Sql.' where username=\''.$username.'\' and id=\''.$id.'\'';
//echo $Sql;

if(!mysql_select_db($Default_db,$conn))
{
	$info->msg="不能连接数据库".mysql_error();
	echo json_encode($info);
	die("");
}
$res=mysql_query($Sql,$conn)or die("$".mysql_error()); ;
$row=mysql_fetch_array($res);
if(!$row) {
	$info->msg="请重新登陆！";
	echo json_encode($info);
	include_once('logout.php');
	die("");
}

else 
{
	if($_COOKIE['session'] != md5($row['id'].$row['username'].$row['password']))
	{
		$info->msg="请重新登陆！";
		echo json_encode($info);
		include_once('logout.php');
		die("");
	}
	else
	{
		session_start();
		$_SESSION['dir']='.\\idedata\\'.$username;
		$info->success=true;
		$info->userid=$row['id'];
		$info->msg="验证成功".$row['username'];
	}
}	
?>

